package com.lagou.zk;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class WebServer {

    public static void main(String[] args) throws SQLException, InterruptedException {
        while (true) {
            //1.获取数据库连接
            Connection conn = JDBCUtils.getConnection();
            //2.定义sql
            String sql = "insert into user(name,age) values (?,?)";
            //3.获取邮差对象
            PreparedStatement ps = conn.prepareStatement(sql);
            //4.给？赋值
            ps.setString(1, "zhangsan");
            ps.setInt(2, 20);
            //5.执行sql
            ps.executeUpdate();
            JDBCUtils.close(ps, conn);
            //方便查看数据库操作
            Thread.sleep(5000);
        }
    }
}
